﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// “用户控件”项模板在 http://go.microsoft.com/fwlink/?LinkId=234236 上提供

namespace Studio77.Timer
{
    public sealed partial class MySelector : UserControl
    {
        public int Value { get; set; }

        public MySelector()
        {
            this.InitializeComponent();
            Value = 0;
        }

        private void ButtonUp_Click(object sender, RoutedEventArgs e)
        {
            Value++;
            if (Value > 59)
            {
                Value = 0;
            }
            this.txtTime.Text = Value.ToString("D2");
        }

        private void ButtonDown_Click(object sender, RoutedEventArgs e)
        {
            Value--;
            if (Value < 0)
            {
                Value = 59;
            }
            this.txtTime.Text = Value.ToString("D2");
        }

        public void SetValue(int value)
        {
            Value = value;
            this.txtTime.Text = Value.ToString("D2");
        }
    }
}
